<?php
namespace app\common\model;
use think\Model;
use think\Db;
class Hand extends Model
{  
	protected $autoWriteTimestamp=true;
	//链接用户表查询该合作need用户offer用户
	public function getAll()
	{
		$result=Db::name('hand h')
		    ->join('user x','h.xid=x.id')
		    ->join('user y','h.yid=y.id')
		    ->join('message m','h.mid=m.id')
		    ->field(['h.id'=>'hid','xid','x.uname'=>'xname','yid','y.uname'=>'yname','mid','m.mname'=>'mname','h.create_time'=>'create_time','h.update_time'=>'update_time'])
		    ->order('create_time desc')
		    ->paginate(4);
		return $result;
	}

	
   //获取该id下过的所有订单
    public function getHandByyid($yid)
    {
		$result=Db::name('hand h')
		    ->join('user x','h.xid=x.id')
		    ->join('user y','h.yid=y.id')
		    ->join('message m','h.mid=m.id')
		    ->where('yid',$yid)
		    ->field(['h.id'=>'hid','xid','x.uname'=>'xname','yid','y.uname'=>'yname','mid','m.mname'=>'mname','h.create_time'=>'create_time','h.update_time'=>'update_time','x.tel'=>'tel'])
		    ->order('create_time desc')
		    ->paginate(4);
		return $result;
	}


    
    //根据id删除一个需求信息
	public function deleteByCondition($where)
	{
		$result=$this->where($where)->delete();
		return $result;
	}
   

}